In [ ]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import cv2
In [ ]:
image = cv2.imread('./Big_Tiger_Cub.jpg')
In [ ]:
cv2.imshow('original image', image)
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f20deabd0>
In [ ]:
kernel_size = (15 , 15 )
smoothed_image = cv2.blur(image, kernel_size)
plt.imshow(cv2.cvtColor(smoothed_image , cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2e718b90>
In [ ]:
kernel_size = 15
smoothed_image = cv2.medianBlur(image, kernel_size)
plt.imshow(cv2.cvtColor(smoothed_image , cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2e758d10>
In [ ]:
img1 = cv2.imread('./Big_Tiger_Cub.jpg')
img2 = cv2.imread('./circle.png')
img2 = cv2.resize(img2, (img1.shape[1], img1.shape[0]))
blend = cv2.addWeighted(img1,0.7,img2,0.3,0)
plt.imshow( cv2.cvtColor(blend , cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2e7f5a50>
In [ ]:
or_op = cv2.bitwise_or(img1 , img2)
# cv2.cvtColor(or_op , cv2.COLOR_BGR2RGB)
plt.imshow(or_op)
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2ea687d0>
In [ ]:
and_op = cv2.bitwise_and(img1 , img2 )
plt.imshow(cv2.cvtColor(and_op , cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2eacdc50>
In [ ]:
not_op = cv2.bitwise_not(img1)
plt.imshow(not_op)
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2eb34f10>
In [ ]:
gaussian_noise = np.random.normal(loc=0, scale=100, size=image.shape)
nois_image = np.clip(image + gaussian_noise , 0 , 255).astype(np.uint8)
plt.imshow(cv2.cvtColor(nois_image , cv2.COLOR_BGR2RGB))
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2ebaa7d0>
In [ ]:
laplacian_kernel_horizontal = np.array([[0, 0, 0],
[1, -2, 1],
[0, 0, 0]])
laplacian_result = cv2.filter2D(image, cv2.CV_64F, laplacian_kernel_horizontal)
laplacian_result_uint8 = np.uint8(np.absolute(laplacian_result))
plt.imshow(laplacian_result_uint8 , cmap='gray')
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2ee18d50>
In [ ]:
sobelx = cv2.Sobel(img1, cv2.CV_64F , 1 , 0 ,5)
plt.imshow(sobelx)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2e6c03d0>
In [ ]:
laplace = cv2.Laplacian(img1 , cv2.CV_64F)
plt.imshow(laplace)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2eeb1790>
In [ ]:
edges = cv2.Canny(image , 100 , 200)
plt.imshow(edges , cmap= 'gray')
Out[Â ]:
<matplotlib.image.AxesImage at 0x24f2ef98490>